<template>
    <div class="components-container">
        <div class="header-form">
            <div class="layui-inline">
                <label class="layui-form-label">电话号码</label>
                <div class="layui-input-inline">
                    <el-input v-model="selectData.SmscallnumLike"></el-input>
                </div>
            </div>
            <el-button type="primary" :disabled="downloadLoading" @click="btnSearch" :loading="this.$store.state.isloading">搜索</el-button>
            <el-button :disabled="this.$store.state.isloading || downloadLoading" @click="btnRepeat">重置</el-button>
        </div>
        <div>
            <ul class="toolList">
                <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
                    <el-button type="primary" :disabled="$store.state.isloading" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
                </li>
                <!-- <li>
                    <el-button type="primary" :disabled="this.$store.state.isloading" @click="exportExcel" style="margin-left:20px;margin-bottom:-10px;">导出Excel</el-button>
                </li> -->
            </ul>
        </div>
        <!-- <dataTable :headList="headList" :dataList="dataList" :isIndex="true" :pageOrder="pageOrder"  :height="height" @pageChange="pageChange" @selectRow="selectRow"></dataTable> -->
        <dataTable :headList="headList" :dataList="dataList" :isIndex="true" :height="height" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable>
        <!-- <cemeteryData ref="simpleReg"  @refreshData="getData"></cemeteryData> -->
        <printmodal ref="printPdf"></printmodal>
        <sendMsgMain ref="simpleReg" :orderType="order" @refreshData="getData"></sendMsgMain>
    </div>
</template>

<script>
import dataTable from "@/components/Table/DataTable";
import sendMsgMain from "./sendMsgMain";

import apiBase from "@/api/apiBase.js";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import { manage } from "@/mixins/managePage.js";
import printmodal from "@/components/Pdf/Print";
import { PRINT } from "@/components/Pdf/PDF.js";
// import cresimplereg from "../businessHall/cresimplereg";
const INFO = "详情";
const send = "发送";
const ADD = "新增";
const CRDETAILS = "火化登记详情";
const MODIFY = "修改";
const DELETE = "删除";
const SPELL = "拼穴";
export default {
    name: "iceuseSearch",
    mixins: [manage],
    data() {
        return {
            all: null,
            selectData: {
                SmscallnumLike: null,
            },
            usetype: [],
            height: "600",
            downloadLoading: false,
        };
    },
    methods: {
        exportExcel() {
            var header = "墓地资料";
            if (this.dataList.length === 0) {
                this.$message.error("无导出数据！");
                return;
            }
            this.downloadLoading = true;
            require.ensure([], () => {
                const {
                    export_json_to_excel
                } = require("@/vendor/Export2Excel");
                export_json_to_excel(this.headList, this.dataList, header);
                this.downloadLoading = false;
            });
        },
        //功能操作
        operate(order) {
            this.order = order;
            switch (this.order) {
                case INFO:
                    this.$refs.simpleReg.open(
                        this.order,
                        this.currentRow.SMSID
                    );
                    break;
                case MODIFY:
                    this.$refs.simpleReg.open("修改", this.currentRow.SMSID);
                    break;
                case ADD:
                    this.$refs.simpleReg.open("新增");
                    break;
                case ADD:
                    this.$refs.simpleReg.open("新增");
                    break;
                case send:
                    this.send();
                default:
            }
        },
        getColumns() {
            let data = {};
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Column.GetShortMsgColumns,
                res => {
                    this.headList = res.data.content;
                }
            );
        },
        getData() {
            let Data = JSON.parse(JSON.stringify(this.selectData));
            let data = {
                PageIndex: this.pageOrder.currentPage,
                PageSize: this.pageOrder.pageSize,
                OrderBy: this.pageOrder.orderType,
                OrderByType: this.pageOrder.orderSort,
                Data: Data
            };
            apiBase.DoService(
                data,
                apiBase.getApiAdress().ShortMsg.Query,
                res => {
                    this.dataList = res.data.content.OutData;
                    this.pageOrder.totalNum = res.data.content.RecordCount;
                }
            );
        },
        send() {
            let data = {
                SMSID: this.currentRow.SMSID
            };
            apiBase.DoService(
                data,
                apiBase.getApiAdress().ShortMsg.Resend,
                res => {
                    // this.usetype = res.data.content;
                    alert("重发成功");
                }
            );
        },
      
        btnShow(btn) {
            switch (btn) {
                case "发送":
                    if(this.currentRow) return true;
                    break;
                case "新增":
                    return true;
                    break;
                case "修改":
                    if(this.currentRow) return true;
                    break;
                case "详情":
                    return true;
                    break;
                default:
                    return false;
            }
        },
        //查询条件重置
        btnRepeat() {
            this.selectData = {
               SmscallnumLike: null
            };
            this.getData();
        }
    },
    mounted() {
     
    },
    components: {
        dataTable,
        sendMsgMain,
        printmodal
    },
    created() {
        this.getColumns(); //获取headerlist
        this.getData(); //获取数据
    }
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
</style>

